﻿using log4net;
using System;
using System.Diagnostics;
/// <summary>
/// log4net
/// </summary>
public class LogHelper
{
    /// <summary>
    /// 普通日志
    /// </summary>
    /// <param name="message">日志内容</param>
    public static void Info(string message)
    {
        ILog log = LogManager.GetLogger("Info");
        if (log.IsInfoEnabled)
        {
            log.Info(message);
        }
    }

    /// <summary>
    /// 错误日志
    /// </summary>
    /// <param name="message">错误日志</param>
    public static void Error(string message)
    {
        ILog log = LogManager.GetLogger("Error");
        if (log.IsErrorEnabled)
        {
            log.Error(message);
        }
    }

    /// <summary>
    /// 生成流水号 通过时间+流水号拼接
    /// </summary>
    /// <returns>流水号</returns>
    public static string GetErrornumber()
    {
        Random rnd = new Random();      
        string randomNumber = rnd.Next(10000, 100000).ToString();
        DateTime dateTime = DateTime.Now;
        return dateTime.ToString("yyyyMMddHHmmss") + "." + randomNumber;
    }
}
